#include "Spring.h"
#include "ADUGameManager.h"

#define PM_RATIO 32.0

Spring::Spring() {
	mSpeed = 0;
}

Spring::~Spring() {

}

void Spring::SetSpeed(float _speed) {
	mSpeed = _speed;
}

void Spring::SetOriginPos(Vec2 _pos) {
	mX = _pos.x;
	mY = _pos.y;
	mYSurface = mY;
}

void Spring::ChangeYSurface(float y){
	mYSurface = y;
}

void Spring::IncreaseHeight(float dy){
	mY += dy;
}

void Spring::SetId(int _id) {
	mId = _id;
}

Vec2 Spring::GetPos() {
	return Vec2(mX, mY);
}

void Spring::OnUpdate(float dt) {
	float delta = mYSurface - mY;
	float delta2;
	delta2 = mTension * delta - mSpeed * mDamping;
	mSpeed += delta2;
	mY += mSpeed;
}
